/*
 * @Date: 2023-08-08 08:51:22
 * @LastEditors: lyx
 * @LastEditTime: 2023-08-14 13:18:18
 * @FilePath: \sup-mini-app\config\index.js
 * @Description: 
 */
const path = require('path');

const config = {
  projectName: 'sup-mini-app',
  date: '2023-8-8',
  designWidth: 750,
  deviceRatio: {
    640: 2.34 / 2,
    750: 1,
    828: 1.81 / 2
  },
  sourceRoot: 'src',
  outputRoot: 'dist',
  plugins: [],
  defineConstants: {
  },
  copy: {
    patterns: [
      {
        from: 'src/wemark',
        to: 'dist/wemark',
      },
    ],
    options: {
    }
  },
  framework: 'react',
  alias: {
    '@/assets': path.resolve(__dirname, '..', 'src/assets'),
    '@/components': path.resolve(__dirname, '..', 'src/components'),
    '@/styles': path.resolve(__dirname, '..', 'src/styles'),
    '@/utils': path.resolve(__dirname, '..', 'src/utils'),
    '@/services': path.resolve(__dirname, '..', 'src/services')
  },
  mini: {
    postcss: {
      pxtransform: {
        enable: true,
        config: {

        }
      },
      url: {
        enable: true,
        config: {
          limit: 1024 // 设定转换尺寸上限
        }
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: 'module', // 转换模式，取值为 global/module
          generateScopedName: '[name]__[local]___[hash:base64:5]'
        }
      }
    }
  },
  weapp: {
    compile: {
      exclude: [
        'src/wemark/remarkable.js',
      ]
    },
  },
  h5: {
    publicPath: '/',
    staticDirectory: 'static',
    esnextModules: ['taro-ui'],
    devServer: {
      proxy: {
        host: 'localhost',
        port: 10086,
        '/api': {
          target: 'http://192.168.182.39:3000/', // 后端地址
          changeOrigin: true,
          pathRewrite: {
            '^/api': ''
          }
        }
      }
    },
    postcss: {
      autoprefixer: {
        enable: true,
        config: {
        }
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: 'module', // 转换模式，取值为 global/module
          generateScopedName: '[name]__[local]___[hash:base64:5]'
        }
      }
    }
  }
}

module.exports = function (merge) {
  if (process.env.NODE_ENV === 'development') {
    return merge({}, config, require('./dev'))
  }
  return merge({}, config, require('./prod'))
}
